
import { useTtsaStore } from '@/store/ttsa'
import { equ } from '../../package-env'
import { createALink } from '@/utils/url'
/**
 * @description 检测app内跳转是否匹配到了指定客户的自定义协议
 * @param url 目标连接地址
 */
export default function useAppRouter(url: string) {
  if (equ !== 'pc') {
    try {
      setTimeout(() => {
        () => location.reload()
      }, 1300)
      /* XXX 跳转前关闭房间 */
      const ttsaStore = useTtsaStore()
      ttsaStore.ttsa.closeRoom()

    } catch {
      /* ignore... */
    } finally {
      location.replace(url)
    }
  } else {
    createALink(url, url)
  }
}
